package com.lq.ecoldchain.base.view

import android.app.Application
import android.content.Context
import com.alibaba.android.arouter.launcher.ARouter
import com.lq.ecoldchain.callback.LifeCallBack
import com.lq.ecoldchain.di.internetModule
import com.lq.ecoldchain.di.prefsModule
import com.lq.ecoldchain.internet.serviceModule
import com.lq.ecoldchain.util.initLogger
import org.kodein.di.Kodein
import org.kodein.di.KodeinAware
import org.kodein.di.android.androidModule
import org.kodein.di.android.support.androidSupportModule
import org.kodein.di.generic.bind
import org.kodein.di.generic.singleton

/*
*2018/12/21 0021  10:35
*function by lq
*/
class App: Application(),KodeinAware{
    companion object {
        lateinit var instance: App
    }

    override val kodein= Kodein.lazy {
        bind<Context>() with singleton { this@App }
        import(androidModule(this@App))
        import(androidSupportModule(this@App))

        import(internetModule)
        import(prefsModule)
        import(serviceModule)
    }

    override fun onCreate() {
        super.onCreate()
        instance = this
        initLogger(true)
        BaseNetCore.initRetrofit()
        registerActivityLifecycleCallbacks(LifeCallBack)
        ARouter.openLog()
        ARouter.openDebug()
        ARouter.init(this)
    }
}